package com.th.therp.mapper;

import com.th.therp.pojo.emtity.MaterialBrand;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MaterialBrandMapper {

    //查找全部商品品牌
    @Select("select * from material_brand where is_deleted = 0")
    List<MaterialBrand> list();

    //新增商品品牌
    @Insert("insert into material_brand (name,is_deleted) values (#{name},0)")
    void add(MaterialBrand materialBrand);

    void update(MaterialBrand materialBrand);

    //根据id查找商品品牌名称
    @Select("select name from material_brand where id=#{brandId}")
    String findBrandNameById(Integer brandId);

    //根据名称查询商品品牌
    @Select("select * from material_brand where name=#{name} and is_deleted=0")
    MaterialBrand findByName(String name);
}